home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-11-24 | 54.2 KB | 2,029 lines |
- Newsgroups: comp.sources.misc
- From: jfh@rpp386.Cactus.ORG (John F Haugh II)
- Subject: v26i063: shadow - Shadow Password Suite, Part10/11
- Message-ID: <1991Nov24.185314.20695@sparky.imd.sterling.com>
- X-Md4-Signature: c3fc9042c69b00bfdd627428ac32c0ec
- Date: Sun, 24 Nov 1991 18:53:14 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: jfh@rpp386.Cactus.ORG (John F Haugh II)
- Posting-number: Volume 26, Issue 63
- Archive-name: shadow/part10
- Environment: UNIX
- Supersedes: shadow-2: Volume 06, Issue 22-24
-
- #! /bin/sh
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # The tool that generated this appeared in the comp.sources.unix newsgroup;
- # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
- # Contents: chage.1 chpasswd.8 console.c entry.c env.c faillog.8
- # hushed.c login.c mkpasswd.8 newusers.8 passwd.4 port.h porttime.4
- # pwd.h.m4 rad64.c shadow.4 shadow.h sppack.c su.1 sub.c sulogin.8
- # ttytype.c valid.c
- # Wrapped by kent@sparky on Sun Nov 24 11:03:44 1991
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 10 (of 11)."'
- if test -f 'chage.1' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'chage.1'\"
- else
- echo shar: Extracting \"'chage.1'\" \(1875 characters\)
- sed "s/^X//" >'chage.1' <<'END_OF_FILE'
- X.\" Copyright 1990, John F. Haugh II
- X.\" All rights reserved.
- X.\"
- X.\" Use, duplication, and disclosure prohibited without
- X.\" the express written permission of the author.
- X.\"
- X.\" @(#)chage.1 3.1 09:34:14 11/21/90
- X.\"
- X.TH CHAGE 1
- X.SH NAME
- Xchage \- change user password expirate information
- X.SH SYNOPSIS
- X\fBchage\fR [ \fB-m \fImindays\fR ] [ \fB-M \fImaxdays\fR ] [ \fB-d \fIlastday\fR ] \fIuser\fR
- X.SH DESCRIPTION
- X\fIchage\f changes the number of days between password changes and the
- Xdate of the last password change.
- XThis information is used by the system to determine when a user must
- Xchange their password.
- XThe \fIchage\f command is restricted to the root user.
- X.PP
- XThe value of \fImindays\f is the minimum number of days between
- Xpassword changes.
- XA value of zero for this field indicates that the user may change
- Xher password at any time.
- X.PP
- XThe value of \fImaxdays\f is the maximum number of days during
- Xwhich a password is valid.
- XWhen \fImaxdays\f plus \fIlastday\f is less than the current day,
- Xthe user will be required to change her password before being
- Xable to use her account.
- X.PP
- XThe value of \fIlastday\f is the number of days since January 1st,
- X1970 when the password was last changed.
- X.PP
- XAll of the above values are stored exactly as days when the shadow
- Xpassword file is used, but are converted to and from weeks when the
- Xstandard password file is used.
- XBecause of this conversion, rounding errors may result.
- X.PP
- XIf none of the options are selected, \fIchage\f operates in an interactive
- Xfashion, prompting the user with the current values for all of the fields.
- XEnter the new value to change the field, or leave the line blank to use
- Xthe current value.
- XThe current value is displayed between a pair of \fB[ ]\f marks.
- X.SH Files
- X/etc/passwd \- user account information
- X.br
- X/etc/shadow \- shadow user account information
- X.SH See Also
- Xpasswd(4),
- Xshadow(4)
- END_OF_FILE
- if test 1875 -ne `wc -c <'chage.1'`; then
- echo shar: \"'chage.1'\" unpacked with wrong size!
- fi
- # end of 'chage.1'
- fi
- if test -f 'chpasswd.8' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'chpasswd.8'\"
- else
- echo shar: Extracting \"'chpasswd.8'\" \(1268 characters\)
- sed "s/^X//" >'chpasswd.8' <<'END_OF_FILE'
- X.\" Copyright 1991, John F. Haugh II
- X.\" All rights reserved.
- X.\"
- X.\" Permission is granted to copy and create derivative works for any
- X.\" non-commercial purpose, provided this copyright notice is preserved
- X.\" in all copies of source code, or included in human readable form
- X.\" and conspicuously displayed on all copies of object code or
- X.\" distribution media.
- X.\"
- X.\" @(#)chpasswd.8 3.1 16:50:16 8/4/91
- X.\"
- X.TH CHPASSWD 8
- X.SH NAME
- X\fBchpasswd\fR - update password file in batch
- X.SH SYNOPSIS
- X\fBchpasswd\fR
- X.SH DESCRIPTION
- X\fBchpasswd\fR reads a file of user name and cleartext password pairs
- Xfrom standard input and uses this information
- Xto update a group of existing users.
- XEach line is of the format
- X.DS
- X \fIuser_name\fR:\fIpassword\fR
- X.DE
- XThe named user must exist.
- XThe supplied password will be encrypted and the password age updated,
- Xif present.
- X.PP
- XThis command is intended to be used in a large system environment where
- Xmany accounts are created at a single time.
- X.SH CAVEATS
- XThe \fImkpasswd\fR command must be executed afterwards to update the
- XDBM password files.
- XThe input file must be protected since it contains unencrypted passwords.
- XThis command may be discarded in favor of the newusers(8) command.
- X.SH SEE ALSO
- Xmkpasswd(8), passwd(1), useradd(1)
- END_OF_FILE
- if test 1268 -ne `wc -c <'chpasswd.8'`; then
- echo shar: \"'chpasswd.8'\" unpacked with wrong size!
- fi
- # end of 'chpasswd.8'
- fi
- if test -f 'console.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'console.c'\"
- else
- echo shar: Extracting \"'console.c'\" \(2025 characters\)
- sed "s/^X//" >'console.c' <<'END_OF_FILE'
- X/*
- X * Copyright 1991, John F. Haugh II and Chip Rosenthal
- X * All rights reserved.
- X *
- X * Permission is granted to copy and create derivative works for any
- X * non-commercial purpose, provided this copyright notice is preserved
- X * in all copies of source code, or included in human readable form
- X * and conspicuously displayed on all copies of object code or
- X * distribution media.
- X */
- X
- X#ifndef lint
- Xstatic char sccsid[] = "@(#)console.c 3.1 07:47:49 9/17/91";
- X#endif
- X
- X#include <stdio.h>
- X#ifndef BSD
- X# include <string.h>
- X#else
- X# include <strings.h>
- X#endif
- X
- Xextern char *getdef_str();
- X
- X/*
- X * tty - return 1 if the "tty" is a console device, else 0.
- X *
- X * Note - we need to take extreme care here to avoid locking out root logins
- X * if something goes awry. That's why we do things like call everything a
- X * console if the consoles file can't be opened. Because of this, we must
- X * warn the user to protect against the remove of the consoles file since
- X * that would allow an unauthorized root login.
- X */
- X
- Xint
- Xconsole (tty)
- Xchar *tty;
- X{
- X FILE *fp;
- X char buf[BUFSIZ], *console, *s;
- X
- X /*
- X * If the CONSOLE configuration definition isn't given, call
- X * everything a valid console.
- X */
- X
- X if ((console = getdef_str("CONSOLE")) == NULL)
- X return 1;
- X
- X /*
- X * If this isn't a filename, then it is a ":" delimited list of
- X * console devices upon which root logins are allowed.
- X */
- X
- X if (*console != '/') {
- X console = strcpy(buf,console);
- X while ((s = strtok(console,":")) != NULL) {
- X if (strcmp(s,tty) == 0)
- X return 1;
- X
- X console = NULL;
- X }
- X return 0;
- X }
- X
- X /*
- X * If we can't open the console list, then call everything a
- X * console - otherwise root will never be allowed to login.
- X */
- X
- X if ((fp = fopen(console,"r")) == NULL)
- X return 1;
- X
- X /*
- X * See if this tty is listed in the console file.
- X */
- X
- X while (fgets(buf,sizeof(buf),fp) != NULL) {
- X buf[strlen(buf)-1] = '\0';
- X if (strcmp(buf,tty) == 0) {
- X (void) fclose(fp);
- X return 1;
- X }
- X }
- X
- X /*
- X * This tty isn't a console.
- X */
- X
- X (void) fclose(fp);
- X return 0;
- X}
- END_OF_FILE
- if test 2025 -ne `wc -c <'console.c'`; then
- echo shar: \"'console.c'\" unpacked with wrong size!
- fi
- # end of 'console.c'
- fi
- if test -f 'entry.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'entry.c'\"
- else
- echo shar: Extracting \"'entry.c'\" \(1994 characters\)
- sed "s/^X//" >'entry.c' <<'END_OF_FILE'
- X/*
- X * Copyright 1989, 1990, 1991, John F. Haugh II
- X * All rights reserved.
- X *
- X * Permission is granted to copy and create derivative works for any
- X * non-commercial purpose, provided this copyright notice is preserved
- X * in all copies of source code, or included in human readable form
- X * and conspicuously displayed on all copies of object code or
- X * distribution media.
- X */
- X
- X#include "pwd.h"
- X#ifndef BSD
- X#include <string.h>
- X#else
- X#include <strings.h>
- X#define strchr index
- X#define strrchr rindex
- X#endif
- X#include "config.h"
- X#ifdef SHADOWPWD
- X#include "shadow.h"
- X#endif
- X
- X#ifndef lint
- Xstatic char sccsid[] = "@(#)entry.c 3.4 08:57:50 7/10/91";
- X#endif
- X
- Xstruct passwd *fgetpwent ();
- Xchar *malloc ();
- X
- Xvoid entry (name, pwent)
- Xchar *name;
- Xstruct passwd *pwent;
- X{
- X struct passwd *passwd;
- X#ifdef SHADOWPWD
- X struct spwd *spwd;
- X char *l64a ();
- X#endif
- X char *cp;
- X char *malloc();
- X
- X if (! (passwd = getpwnam (name))) {
- X pwent->pw_name = (char *) 0;
- X return;
- X } else {
- X pwent->pw_name = strdup (passwd->pw_name);
- X pwent->pw_uid = passwd->pw_uid;
- X pwent->pw_gid = passwd->pw_gid;
- X#ifdef ATT_COMMENT
- X pwent->pw_comment = strdup (passwd->pw_comment);
- X#endif
- X pwent->pw_gecos = strdup (passwd->pw_gecos);
- X pwent->pw_dir = strdup (passwd->pw_dir);
- X pwent->pw_shell = strdup (passwd->pw_shell);
- X#if defined(SHADOWPWD) && !defined(AUTOSHADOW)
- X setspent ();
- X if (spwd = getspnam (name)) {
- X pwent->pw_passwd = strdup (spwd->sp_pwdp);
- X#ifdef ATT_AGE
- X pwent->pw_age = (char *) malloc (5);
- X
- X if (spwd->sp_max > (63*7))
- X spwd->sp_max = (63*7);
- X if (spwd->sp_min > (63*7))
- X spwd->sp_min = (63*7);
- X
- X pwent->pw_age[0] = i64c (spwd->sp_max / 7);
- X pwent->pw_age[1] = i64c (spwd->sp_min / 7);
- X
- X cp = l64a (spwd->sp_lstchg / 7);
- X pwent->pw_age[2] = cp[0];
- X pwent->pw_age[3] = cp[1];
- X
- X pwent->pw_age[4] = '\0';
- X#endif
- X endspent ();
- X return;
- X }
- X endspent ();
- X#endif
- X pwent->pw_passwd = strdup (passwd->pw_passwd);
- X#ifdef ATT_AGE
- X pwent->pw_age = strdup (passwd->pw_age);
- X#endif
- X }
- X}
- END_OF_FILE
- if test 1994 -ne `wc -c <'entry.c'`; then
- echo shar: \"'entry.c'\" unpacked with wrong size!
- fi
- # end of 'entry.c'
- fi
- if test -f 'env.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'env.c'\"
- else
- echo shar: Extracting \"'env.c'\" \(1788 characters\)
- sed "s/^X//" >'env.c' <<'END_OF_FILE'
- X/*
- X * Copyright 1989, 1990, John F. Haugh II
- X * All rights reserved.
- X *
- X * Use, duplication, and disclosure prohibited without
- X * the express written permission of the author.
- X */
- X
- X#include <stdio.h>
- X#ifndef BSD
- X#include <string.h>
- X#else
- X#define strchr index
- X#define strrchr rindex
- X#include <strings.h>
- X#endif
- X
- X#ifndef lint
- Xstatic char _sccsid[] = "@(#)env.c 2.2 19:23:43 7/29/90";
- X#endif
- X
- Xextern char **environ;
- Xextern char *newenvp[];
- Xextern int newenvc;
- Xextern int maxenv;
- X
- Xchar *strdup ();
- Xvoid free ();
- X
- Xstatic char *forbid[] = {
- X "HOME",
- X "IFS",
- X "PATH",
- X "SHELL",
- X (char *) 0
- X};
- X
- Xvoid addenv (entry)
- Xchar *entry;
- X{
- X char *cp;
- X int i;
- X int len;
- X
- X if (cp = strchr (entry, '='))
- X len = cp - entry;
- X else
- X return;
- X
- X for (i = 0;i < newenvc;i++)
- X if (strncmp (entry, newenvp[i], len) == 0 &&
- X (newenvp[i][len] == '=' || newenvp[i][len] == '\0'))
- X break;
- X
- X if (i == maxenv) {
- X puts ("Environment overflow");
- X return;
- X }
- X if (i == newenvc) {
- X newenvp[newenvc++] = strdup (entry);
- X } else {
- X free (newenvp[i]);
- X newenvp[i] = strdup (entry);
- X }
- X}
- X
- Xvoid setenv (argc, argv)
- Xint argc;
- Xchar **argv;
- X{
- X int i;
- X int n;
- X int noname = 1;
- X char variable[BUFSIZ];
- X char *cp;
- X
- X for (i = 0;i < argc;i++) {
- X if ((n = strlen (argv[i])) >= BUFSIZ)
- X continue; /* ignore long entries */
- X
- X if (! (cp = strchr (argv[i], '='))) {
- X (void) strcpy (variable, argv[i]);
- X } else {
- X (void) strncpy (variable, argv[i], cp - argv[i]);
- X variable[cp - argv[i]] = '\0';
- X }
- X for (n = 0;forbid[n] != (char *) 0;n++)
- X if (strcmp (variable, forbid[n]) == 0)
- X break;
- X
- X if (forbid[n] != (char *) 0) {
- X printf ("You may not change $%s\n", forbid[n]);
- X continue;
- X }
- X if (cp) {
- X addenv (argv[i]);
- X } else {
- X sprintf (variable, "L%d=%s", noname++, argv[i]);
- X addenv (variable);
- X }
- X }
- X}
- END_OF_FILE
- if test 1788 -ne `wc -c <'env.c'`; then
- echo shar: \"'env.c'\" unpacked with wrong size!
- fi
- # end of 'env.c'
- fi
- if test -f 'faillog.8' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'faillog.8'\"
- else
- echo shar: Extracting \"'faillog.8'\" \(2030 characters\)
- sed "s/^X//" >'faillog.8' <<'END_OF_FILE'
- X.\" Copyright 1989, 1990, John F. Haugh II
- X.\" All rights reserved.
- X.\"
- X.\" Use, duplication, and disclosure prohibited without
- X.\" the express written permission of the author.
- X.\"
- X.\" @(#)faillog.8 3.1 09:34:20 11/21/90
- X.\"
- X.TH FAILLOG 8
- X.SH NAME
- Xfaillog \- examine faillog and set login failure limits
- X.SH SYNOPSIS
- X/etc/faillog [ -u uid ] [ -t days ] [ -m max ] [ -pr ]
- X.SH DESCRIPTION
- X\fIPlastlog\fR formats the contents of the failure log,
- X\fI/usr/adm/faillog\fR, and maintains failure counts and
- Xlimits.
- XThe order of the arguments to \fIfaillog\fR is significant.
- XEach argument is processed immediately in the order given.
- X.PP
- XThe \fB-p\fR flag causes failure entries to be printed in UID
- Xorder.
- XEntering \fB-u login-name\fR flag will
- Xcause the failure record for \fBlogin-name\fR only to be printed.
- XEntering \fB-t days\fR will cause only the
- Xfailures more recent than \fBdays\fR to be printed.
- XThe \fB-t\fR flag overrides the use of \fB-u\fR.
- X.PP
- XThe \fB-r\fR flag is used to reset the count of login failures.
- XWrite access to \fI/usr/adm/faillog\fR is required for
- Xthis option.
- XEntering \fB-u login-name\fR will cause only the failure count
- Xfor \fBlogin-name\fR to be reset.
- X.PP
- XThe \fB-m\fR flag is used to set the maximum number of login
- Xfailures before the account is disabled.
- XWrite access to \fB/usr/adm/faillog\fR is required for this
- Xoption.
- XEntering \fB-m max\fR will cause all accounts to be disabled
- Xafter \fBmax\fR failed logins occur.
- XThis may be modified with \fB-u login-name\fR to limit this
- Xfunction to \fBlogin-name\fR only.
- XSelecting a \fBmax\fR value of 0 has the effect of not placing
- Xa limit on the number of failed logins.
- XThe maximum failure count
- Xshould always be 0 for \fBroot\fR to prevent
- Xa denial of services attack against the system.
- X.PP
- XOptions may be combined in virtually any fashion.
- XEach \fB-p\fR, \fB-r\fR, and \fB-m\fR option will cause
- Ximmediate execution using any \fB-u\fR or \fB-t\fR modifier.
- X.SH Files
- X/usr/adm/faillog \- failure logging file
- X.SH See Also
- Xlogin(1),
- Xfaillog(4)
- END_OF_FILE
- if test 2030 -ne `wc -c <'faillog.8'`; then
- echo shar: \"'faillog.8'\" unpacked with wrong size!
- fi
- # end of 'faillog.8'
- fi
- if test -f 'hushed.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'hushed.c'\"
- else
- echo shar: Extracting \"'hushed.c'\" \(1678 characters\)
- sed "s/^X//" >'hushed.c' <<'END_OF_FILE'
- X/*
- X * Copyright 1991, John F. Haugh II and Chip Rosenthal
- X * All rights reserved.
- X *
- X * Permission is granted to copy and create derivative works for any
- X * non-commercial purpose, provided this copyright notice is preserved
- X * in all copies of source code, or included in human readable form
- X * and conspicuously displayed on all copies of object code or
- X * distribution media.
- X */
- X
- X#ifndef lint
- Xstatic char sccsid[] = "@(#)hushed.c 3.1 07:47:53 9/17/91";
- X#endif
- X
- X#include <stdio.h>
- X#ifndef BSD
- X# include <string.h>
- X#else
- X# include <strings.h>
- X#endif
- X#include "config.h"
- X#include "pwd.h"
- X
- Xextern char *getdef_str();
- X
- X/*
- X * hushed - determine if a user receives login messages
- X *
- X * Look in the hushed-logins file (or user's home directory) to see
- X * if the user is to receive the login-time messages.
- X */
- X
- Xint
- Xhushed(pw)
- Xstruct passwd *pw;
- X{
- X char *hushfile;
- X char buf[BUFSIZ];
- X int found;
- X FILE *fp;
- X
- X /*
- X * Get the name of the file to use. If this option is not
- X * defined, default to a noisy login.
- X */
- X
- X if ( (hushfile=getdef_str("HUSHLOGIN_FILE")) == NULL )
- X return 0;
- X
- X /*
- X * If this is not a fully rooted path then see if the
- X * file exists in the user's home directory.
- X */
- X
- X if (hushfile[0] != '/') {
- X strcat(strcat(strcpy(buf, pw->pw_dir), "/"), hushfile);
- X return (access(buf, 0) == 0);
- X }
- X
- X /*
- X * If this is a fully rooted path then go through the file
- X * and see if this user is in there.
- X */
- X
- X if ((fp = fopen(hushfile, "r")) == NULL)
- X return 0;
- X
- X for (found = 0;! found && fgets (buf, sizeof buf, fp);) {
- X buf[strlen (buf) - 1] = '\0';
- X found = ! strcmp (buf,
- X buf[0] == '/' ? pw->pw_shell:pw->pw_name);
- X }
- X (void) fclose(fp);
- X return found;
- X}
- END_OF_FILE
- if test 1678 -ne `wc -c <'hushed.c'`; then
- echo shar: \"'hushed.c'\" unpacked with wrong size!
- fi
- # end of 'hushed.c'
- fi
- if test -f 'login.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'login.c'\"
- else
- echo shar: Extracting \"'login.c'\" \(1840 characters\)
- sed "s/^X//" >'login.c' <<'END_OF_FILE'
- X/*
- X * Copyright 1989, 1990, 1991, John F. Haugh II
- X * All rights reserved.
- X *
- X * Permission is granted to copy and create derivative works for any
- X * non-commercial purpose, provided this copyright notice is preserved
- X * in all copies of source code, or included in human readable form
- X * and conspicuously displayed on all copies of object code or
- X * distribution media.
- X */
- X
- X#include <stdio.h>
- X#include <ctype.h>
- X#ifndef BSD
- X#include <string.h>
- X#include <memory.h>
- X#else
- X#include <strings.h>
- X#define strchr index
- X#define strrchr rindex
- X#endif
- X
- X#ifndef lint
- Xstatic char sccsid[] = "@(#)login.c 3.1 20:54:10 9/18/91";
- X#endif
- X
- Xvoid setenv ();
- X
- X/*
- X * login - prompt the user for their login name
- X *
- X * login() displays the standard login prompt. If the option
- X * ISSUE_FILE_ENAB is set, the file /etc/issue is displayed
- X * before the prompt.
- X */
- X
- Xvoid
- Xlogin (name)
- Xchar *name;
- X{
- X char buf[BUFSIZ];
- X char *envp[32];
- X int envc;
- X char *cp;
- X int i;
- X FILE *fp;
- X
- X /*
- X * See if the user has configured the /etc/issue file to
- X * be displayed.
- X */
- X
- X if (getdef_bool ("ISSUE_FILE_ENAB")) {
- X if (fp = fopen ("/etc/issue", "r")) {
- X while ((i = getc (fp)) != EOF)
- X putc (i, stdout);
- X
- X fflush (stdout);
- X fclose (fp);
- X }
- X }
- X#ifndef BSD
- X (void) memset (buf, '\0', sizeof buf);
- X#else
- X bzero (buf, sizeof buf);
- X#endif
- X fputs ("login: ", stdout);
- X
- X if (fgets (buf, BUFSIZ, stdin) != buf)
- X exit (1);
- X
- X buf[strlen (buf) - 1] = '\0'; /* remove \n [ must be there ] */
- X
- X for (cp = buf;*cp == ' ' || *cp == '\t';cp++)
- X ;
- X
- X for (i = 0;i < BUFSIZ - 1 && isgraph (*cp);name[i++] = *cp++)
- X ;
- X
- X if (*cp)
- X cp++;
- X
- X name[i] = '\0';
- X
- X if (*cp != '\0') { /* process new variables */
- X for (envc = 0;envc < 32;envc++) {
- X envp[envc] = strtok (envc == 0 ? cp:(char *) 0, " \t,");
- X
- X if (envp[envc] == (char *) 0)
- X break;
- X }
- X setenv (envc, envp);
- X }
- X}
- END_OF_FILE
- if test 1840 -ne `wc -c <'login.c'`; then
- echo shar: \"'login.c'\" unpacked with wrong size!
- fi
- # end of 'login.c'
- fi
- if test -f 'mkpasswd.8' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'mkpasswd.8'\"
- else
- echo shar: Extracting \"'mkpasswd.8'\" \(2125 characters\)
- sed "s/^X//" >'mkpasswd.8' <<'END_OF_FILE'
- X.\" Copyright 1991, John F. Haugh II
- X.\" All rights reserved.
- X.\"
- X.\" Permission is granted to copy and create derivative works for any
- X.\" non-commercial purpose, provided this copyright notice is preserved
- X.\" in all copies of source code, or included in human readable form
- X.\" and conspicuously displayed on all copies of object code or
- X.\" distribution media.
- X.\"
- X.\" @(#)mkpasswd.8 3.1 07:49:05 7/13/91
- X.\"
- X.TH MKPASSWD 1
- X.SH NAME
- Xmkpasswd \- Update passwd and group database files
- X.SH SYNOPSIS
- X\fBmkpasswd\fR [ \fB-fvgps\fR ] \fIfile\fR
- X.SH DESCRIPTION
- X.I mkpasswd
- Xreads the file in the format given by the flags and converts it to the
- Xcorresponding database file format.
- XThese database files are used to improve access performance on systems
- Xwith large numbers of users.
- XThe output files will be named \fIfile\fR.dir and \fIfile\fR.pag.
- X.PP
- XThe \fB-f\fR option causes \fImkpasswd\fR to ignore any existing output
- Xfiles and overwrite them.
- XNormally \fImkpasswd\fR complains about existing output files and quits.
- X.PP
- XThe \fB-v\fR option causes \fImkpasswd\fR to output information about
- Xeach record as it is converted, with a final message at the very end.
- X.PP
- XThe \fB-g\fR option treats the input file as though it were in
- X\fB/etc/group\fR file format.
- XWhen combined with the \fB-s\fR option, the \fB/etc/gshadow\fR file
- Xformat is used instead.
- X.PP
- XThe \fB-p\fR option treats the input file as though it were in
- X\fB/etc/passwd\fR file format.
- XThis is the default.
- XWhen combined with the \fB-s\fR option, the \fB/etc/shadow\fR file
- Xformat is used instead.
- X.SH CAVEATS
- XThe use of more than one database file is limited to systems which
- Xinclude the NDBM database library and therefore may not be available
- Xon every system.
- X.SH Note
- XSince most commands are capable of updating the database files as
- Xchanges are made, this command need only be used when re-creating a
- Xdeleted or corrupted database file.
- X.SH Files
- X/etc/passwd \- user account information
- X.br
- X/etc/shadow \- shadow user information
- X.br
- X/etc/group \- group information
- X.br
- X/etc/gshadow \- shadow group information
- X.SH See Also
- Xpasswd(4), group(4), shadow(4)
- END_OF_FILE
- if test 2125 -ne `wc -c <'mkpasswd.8'`; then
- echo shar: \"'mkpasswd.8'\" unpacked with wrong size!
- fi
- # end of 'mkpasswd.8'
- fi
- if test -f 'newusers.8' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'newusers.8'\"
- else
- echo shar: Extracting \"'newusers.8'\" \(1805 characters\)
- sed "s/^X//" >'newusers.8' <<'END_OF_FILE'
- X.\" Copyright 1991, John F. Haugh II
- X.\" All rights reserved.
- X.\"
- X.\" Permission is granted to copy and create derivative works for any
- X.\" non-commercial purpose, provided this copyright notice is preserved
- X.\" in all copies of source code, or included in human readable form
- X.\" and conspicuously displayed on all copies of object code or
- X.\" distribution media.
- X.\"
- X.\" @(#)newusers.8 3.1 16:49:47 8/4/91
- X.\"
- X.TH NEWUSERS 8
- X.SH NAME
- X\fBnewusers\fR - update and create new users in batch
- X.SH SYNOPSIS
- X\fBnewusers\fR
- X[ \fI new_users \fR ]
- X.SH DESCRIPTION
- X\fBnewusers\fR reads a file of user name and cleartext password pairs
- Xand uses this information to update a group of existing users or to
- Xcreate new users.
- XEach line is in the same format as the standard password file (see
- X\fIpasswd(4)\fR) with the following exceptions.
- X.IP "pw_passwd"
- XThis field will be encrypted and used as the new value
- Xof the encrpted password.
- X.IP "pw_age"
- XThis field will be ignored for shadow passwords if the user already
- Xexists.
- X.IP "pw_gid"
- XThis field may be the name of an existing group, in which case the
- Xnamed user will be added as a member. If a non-existent numerical
- Xgroup is given, a new group will be created having this number.
- X.IP "pw_dir"
- XThis field will be checked for existence as a directory and a new
- Xdirectory will the same name created if it does not already exist.
- XThe ownership of the directory will be set to be that of the user
- Xbeing created or updated.
- X.PP
- XThis command is intended to be used in a large system environment where
- Xmany accounts are updated at a single time.
- X.SH CAVEATS
- XThe \fImkpasswd\fR command must be executed afterwards to update the
- XDBM password files.
- XThe input file must be protected since it contains unencrypted passwords.
- X.SH SEE ALSO
- Xmkpasswd(8), passwd(1), useradd(1)
- END_OF_FILE
- if test 1805 -ne `wc -c <'newusers.8'`; then
- echo shar: \"'newusers.8'\" unpacked with wrong size!
- fi
- # end of 'newusers.8'
- fi
- if test -f 'passwd.4' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'passwd.4'\"
- else
- echo shar: Extracting \"'passwd.4'\" \(2520 characters\)
- sed "s/^X//" >'passwd.4' <<'END_OF_FILE'
- X.\" Copyright 1989, 1990, John F. Haugh II
- X.\" All rights reserved.
- X.\"
- X.\" Use, duplication, and disclosure prohibited without
- X.\" the express written permission of the author.
- X.\"
- X.\" @(#)passwd.4 3.1 09:34:24 11/21/90
- X.\"
- X.TH PASSWD 4
- X.SH NAME
- Xpasswd \- The password file
- X.SH DESCRIPTION
- X.I passwd
- Xcontains various pieces of information for each user account.
- XIncluded is
- X.IP "" .5i
- XLogin name
- X.IP "" .5i
- XOptional encrypted password
- X.IP "" .5i
- XNumerical user ID
- X.IP "" .5i
- XNumerical group ID
- X.IP "" .5i
- XUser name or comment field
- X.IP "" .5i
- XUser home directory
- X.IP "" .5i
- XUser command interpreter
- X.PP
- XThe password field may not be filled if shadow passwords
- Xhave been enabled.
- XIf shadow passwords are being used, the encrypted password will
- Xbe found in \fB/etc/shadow\fR.
- XThe encryped password consists of 13 characters from the
- X64 character alphabet
- Xa thru z, A thru Z, 0 thru 9, \. and /.
- XRefer to \fIcrypt(3)\fR for details on how this string is
- Xinterpreted.
- X.PP
- XAn optional password age string may follow the encrypted
- Xpassword, separated by a comma, from the same alphabet
- Xas the password itself.
- XThe first character gives the number of weeks during which the
- Xpassword is valid.
- XThe second character gives the number of weeks which must pass
- Xbefore the user is permitted to change the password.
- XThe last two characters give the week since Jan 1970 when the
- Xpassword was last changed.
- XWhen the number of weeks during which the password is valid
- Xhave passed, the user will be required to provide a new
- Xpassword.
- X.PP
- XThe comment field is used by various system utilities, such as
- X\fIfinger(1)\fR.
- XThree additional values may be present in the comment field.
- XThey are
- X.IP "" .5i
- Xpri= \- set initial value of nice
- X.IP "" .5i
- Xumask= \- set initial value of umask
- X.IP "" .5i
- Xulimit= \- set initial value of ulimit
- X.PP
- XThese fields are separated from each other and from any other
- Xcomment field by a comma.
- X.PP
- XThe home directory field provides the name of the initial
- Xworking directory.
- X\fILogin\fR uses this information to set the value of
- Xthe \fBHOME\fR environmental variable.
- X.PP
- XThe command interpreter field provides the name of the user's
- Xcommand language interpreter, or the name of the initial program
- Xto execute.
- X\fILogin\fR uses this information to set the value of the
- X\fBSHELL\fR environmental variable.
- XIf this field is empty, it defaults to the value \fB/bin/sh\fR.
- X.SH Files
- X/etc/passwd \- user account information
- X.SH See Also
- Xlogin(1),
- Xpasswd(1),
- Xsu(1),
- Xsulogin(1M),
- Xshadow(4),
- Xpwconv(8),
- Xpwunconv(8)
- END_OF_FILE
- if test 2520 -ne `wc -c <'passwd.4'`; then
- echo shar: \"'passwd.4'\" unpacked with wrong size!
- fi
- # end of 'passwd.4'
- fi
- if test -f 'port.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'port.h'\"
- else
- echo shar: Extracting \"'port.h'\" \(1743 characters\)
- sed "s/^X//" >'port.h' <<'END_OF_FILE'
- X/*
- X * Copyright 1989, 1990, 1991, John F. Haugh II
- X * All rights reserved.
- X *
- X * Permission is granted to copy and create derivative works for any
- X * non-commercial purpose, provided this copyright notice is preserved
- X * in all copies of source code, or included in human readable form
- X * and conspicuously displayed on all copies of object code or
- X * distribution media.
- X */
- X
- X/*
- X * port.h - structure of /etc/porttime
- X *
- X * @(#)port.h 3.1 08:59:36 2/8/91
- X *
- X * Each entry in /etc/porttime consists of a TTY device
- X * name or "*" to indicate all TTY devices, followed by
- X * a list of 1 or more user IDs or "*" to indicate all
- X * user names, followed by a list of zero or more valid
- X * login times. Login time entries consist of zero or
- X * more day names (Su, Mo, Tu, We, Th, Fr, Sa, Wk, Al)
- X * followed by a pair of time values in HHMM format
- X * separated by a "-".
- X */
- X
- X/*
- X * PORTS - Name of system port access time file.
- X * PORT_IDS - Allowable number of IDs per entry.
- X * PORT_TTY - Allowable number of TTYs per entry.
- X * PORT_TIMES - Allowable number of time entries per entry.
- X * PORT_DAY - Day of the week to a bit value (0 = Sunday).
- X */
- X
- X#define PORTS "/etc/porttime"
- X#define PORT_IDS 64
- X#define PORT_TTY 64
- X#define PORT_TIMES 24
- X#define PORT_DAY(day) (1<<(day))
- X
- X/*
- X * pt_names - pointer to array of device names in /dev/
- X * pt_users - pointer to array of applicable user IDs.
- X * pt_times - pointer to list of allowable time periods.
- X */
- X
- Xstruct port {
- X char **pt_names;
- X char **pt_users;
- X struct pt_time *pt_times;
- X};
- X
- X/*
- X * t_days - bit array for each day of the week (0 = Sunday)
- X * t_start - starting time for this entry
- X * t_end - ending time for this entry
- X */
- X
- Xstruct pt_time {
- X short t_days;
- X short t_start;
- X short t_end;
- X};
- END_OF_FILE
- if test 1743 -ne `wc -c <'port.h'`; then
- echo shar: \"'port.h'\" unpacked with wrong size!
- fi
- # end of 'port.h'
- fi
- if test -f 'porttime.4' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'porttime.4'\"
- else
- echo shar: Extracting \"'porttime.4'\" \(1872 characters\)
- sed "s/^X//" >'porttime.4' <<'END_OF_FILE'
- X.\" Copyright 1989, 1990, John F. Haugh II
- X.\" All rights reserved.
- X.\"
- X.\" Use, duplication, and disclosure prohibited without
- X.\" the express written permission of the author.
- X.\"
- X.\" @(#)porttime.4 3.2 08:36:07 2/8/91
- X.\"
- X.TH PORTTIME 4
- X.SH NAME
- Xporttime \- port access time file
- X.SH DESCRIPTION
- X.I porttime
- Xcontains a list of tty devices, user names, and permitted login times.
- X.PP
- XEach entry consists of three colon separated fields.
- XThe first field is a comma separated list of tty devices,
- Xor an asterisk to indicate that all tty devices are matched by this entry.
- XThe second field is a comma separated list of user names, or an
- Xasterisk to indicated that all user names are matched by this entry.
- XThe third field is a comma separated list of permitted access times.
- X.PP
- XEach access time entry consists of zero or more days of the week,
- Xabbreviated \fBSu\fR, \fBMo\fR, \fBTu\fR, \fBWe\fR, \fBTh\fR,
- X\fBFr\fR, and \fBSa\fR, followed by a pair of times separated by
- Xa hyphen.
- XThe abbreviation \fBWk\fR may be used to represent Monday thru Friday,
- Xand \fBAl\fR may be used to indicate every day.
- XIf no days are given, \fBAl\fR is assumed.
- X.SH Examples
- XThe following entry allows access to user \fBjfh\fR on every port
- Xduring weekdays from 9am to 5pm.
- X.br
- X.sp 1
- X*:jfh:Wk0900-1700
- X.br
- X.sp 1
- XThe following entries allow access only to the users \fBroot\fR and
- X\fBoper\fR on /dev/console at any time.
- XThis illustrates how the
- X\fB/etc/porttime\fR file is an ordered list of access times.
- XAny other user would match the second entry which does not permit
- Xaccess at any time.
- X.br
- X.sp 1
- Xconsole:root,oper:Al0000-2400
- X.br
- Xconsole:*:
- X.br
- X.sp 1
- XThe following entry allows access for the user \fBgames\fR on any
- Xport during non-working hours.
- X.br
- X.sp 1
- X*:games:Wk1700-0900,SaSu0000-2400
- X.br
- X.sp 1
- X.SH Files
- X/etc/porttime \- file containing port access times
- X.SH See Also
- Xlogin(1)
- END_OF_FILE
- if test 1872 -ne `wc -c <'porttime.4'`; then
- echo shar: \"'porttime.4'\" unpacked with wrong size!
- fi
- # end of 'porttime.4'
- fi
- if test -f 'pwd.h.m4' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'pwd.h.m4'\"
- else
- echo shar: Extracting \"'pwd.h.m4'\" \(2347 characters\)
- sed "s/^X//" >'pwd.h.m4' <<'END_OF_FILE'
- X/*
- X * Copyright 1990, 1991, John F. Haugh II and Steve Simmons
- X * All rights reserved.
- X *
- X * Permission is granted to copy and create derivative works for any
- X * non-commercial purpose, provided this copyright notice is preserved
- X * in all copies of source code, or included in human readable form
- X * and conspicuously displayed on all copies of object code or
- X * distribution media.
- X */
- X
- X/*
- X * Standard definitions for password files. This is an independant
- X * reimplementation of the definitions used by AT&T, BSD, and POSIX.
- X * It is not derived from any of those sources. Note that it can be
- X * site-defined to have non-POSIX features as well.
- X *
- X * @(#)pwd.h.m4 3.1 08:54:41 11/3/91
- X */
- X
- X#ifndef PWD_H
- X#define PWD_H
- X
- X#ifdef M_XENIX
- Xtypedef int uid_t;
- Xtypedef int gid_t;
- X#endif
- X
- X#ifdef SUN
- X#include <sys/types.h>
- X#endif
- X
- Xifdef(`SUN', `#define BSD_QUOTAS')
- Xifdef(`BSD', `#define BSD_QUOTAS')
- Xifdef(`USG', `#define ATT_AGE')
- Xifdef(`USG', `#define ATT_COMMENT')
- X
- X/*
- X * This is the data structure returned by the getpw* functions. The
- X * names of the elements and the structure are taken from traditional
- X * usage.
- X */
- X
- Xstruct passwd {
- X char *pw_name ; /* User login name */
- X char *pw_passwd ; /* Encrypted passwd or dummy field */
- X uid_t pw_uid ; /* User uid number */
- X gid_t pw_gid ; /* User group id number */
- X#ifdef BSD_QUOTAS
- X /* Most BSD systems have quotas, most USG ones don't */
- X int pw_quota ; /* The BSD magic doodah */
- X#endif
- X#ifdef ATT_AGE
- X /* Use ATT-style password aging */
- X char *pw_age ; /* ATT radix-64 encoded data */
- X#endif
- X#ifdef ATT_COMMENT
- X /* Provide the unused comment field */
- X char *pw_comment; /* Unused comment field */
- X#endif
- X char *pw_gecos ; /* ASCII user name, other data */
- X char *pw_dir ; /* User home directory */
- X char *pw_shell ; /* User startup shell */
- X} ;
- X
- X#ifdef ATT_COMMENT
- X/* Provide the unused comment structure */
- Xstruct comment {
- X char *c_dept;
- X char *c_name;
- X char *c_acct;
- X char *c_bin;
- X};
- X#endif
- X
- X#if __STDC__
- X
- Xextern struct passwd *getpwent( void ) ;
- Xextern struct passwd *getpwuid( uid_t user_uid ) ;
- Xextern struct passwd *getpwnam( char *name ) ;
- Xint setpwent( void );
- Xint endpwent( void );
- X
- X#else
- X
- Xextern struct passwd *getpwent();
- Xextern struct passwd *getpwuid();
- Xextern struct passwd *getpwnam();
- Xint setpwent();
- Xint endpwent();
- X
- X#endif /* of if __STDC__ */
- X
- X#endif /* of ifdef PWD_H */
- END_OF_FILE
- if test 2347 -ne `wc -c <'pwd.h.m4'`; then
- echo shar: \"'pwd.h.m4'\" unpacked with wrong size!
- fi
- # end of 'pwd.h.m4'
- fi
- if test -f 'rad64.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'rad64.c'\"
- else
- echo shar: Extracting \"'rad64.c'\" \(1670 characters\)
- sed "s/^X//" >'rad64.c' <<'END_OF_FILE'
- X/*
- X * Copyright 1989, 1990, John F. Haugh II
- X * All rights reserved.
- X *
- X * Permission is granted to copy and create derivative works for any
- X * non-commercial purpose, provided this copyright notice is preserved
- X * in all copies of source code, or included in human readable form
- X * and conspicuously displayed on all copies of object code or
- X * distribution media.
- X */
- X
- X#ifndef lint
- Xstatic char sccsid[] = "@(#)rad64.c 3.2 19:44:25 12/10/90";
- X#endif
- X
- X/*
- X * c64i - convert a radix 64 character to an integer
- X */
- X
- Xint c64i (c)
- Xchar c;
- X{
- X if (c == '.')
- X return (0);
- X
- X if (c == '/')
- X return (1);
- X
- X if (c >= '0' && c <= '9')
- X return (c - '0' + 2);
- X
- X if (c >= 'A' && c <= 'Z')
- X return (c - 'A' + 12);
- X
- X if (c >= 'a' && c <= 'z')
- X return (c - 'a' + 38);
- X else
- X return (-1);
- X}
- X
- X/*
- X * i64c - convert an integer to a radix 64 character
- X */
- X
- Xint i64c (i)
- Xint i;
- X{
- X if (i < 0)
- X return ('.');
- X else if (i > 63)
- X return ('z');
- X
- X if (i == 0)
- X return ('.');
- X
- X if (i == 1)
- X return ('/');
- X
- X if (i >= 2 && i <= 11)
- X return ('0' - 2 + i);
- X
- X if (i >= 12 && i <= 37)
- X return ('A' - 12 + i);
- X
- X if (i >= 38 && i <= 63)
- X return ('a' - 38 + i);
- X
- X return ('\0');
- X}
- X
- X/*
- X * l64a - convert a long to a string of radix 64 characters
- X */
- X
- Xchar *l64a (l)
- Xlong l;
- X{
- X static char buf[8];
- X int i = 0;
- X
- X if (i < 0L)
- X return ((char *) 0);
- X
- X do {
- X buf[i++] = i64c ((int) (l % 64));
- X buf[i] = '\0';
- X } while (l /= 64L, l > 0 && i < 6);
- X
- X return (buf);
- X}
- X
- X/*
- X * a64l - convert a radix 64 string to a long integer
- X */
- X
- Xlong a64l (s)
- Xchar *s;
- X{
- X int i;
- X long value;
- X long shift = 0;
- X
- X for (i = 0, value = 0L;i < 6 && *s;s++) {
- X value += (c64i (*s) << shift);
- X shift += 6;
- X }
- X return (value);
- X}
- END_OF_FILE
- if test 1670 -ne `wc -c <'rad64.c'`; then
- echo shar: \"'rad64.c'\" unpacked with wrong size!
- fi
- # end of 'rad64.c'
- fi
- if test -f 'shadow.4' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'shadow.4'\"
- else
- echo shar: Extracting \"'shadow.4'\" \(2122 characters\)
- sed "s/^X//" >'shadow.4' <<'END_OF_FILE'
- X.\" Copyright 1989, 1990, John F. Haugh II
- X.\" All rights reserved.
- X.\"
- X.\" Use, duplication, and disclosure prohibited without
- X.\" the express written permission of the author.
- X.\"
- X.\" @(#)shadow.4 3.1 23:49:44 11/11/90
- X.\"
- X.TH SHADOW 4
- X.SH NAME
- Xshadow \- encrypted password file
- X.SH DESCRIPTION
- X.I shadow
- Xcontains the encrypted password information for user's accounts
- Xand optional the password aging information.
- XIncluded is
- X.IP "" .5i
- XLogin name
- X.IP "" .5i
- XEncrypted password
- X.IP "" .5i
- XDays since Jan 1, 1970 that password was last changed
- X.IP "" .5i
- XDays before password may be changed
- X.IP "" .5i
- XDays after which password must be changed
- X.IP "" .5i
- XDays before password is to expire that user is warned
- X.IP "" .5i
- XDays after password expires that account is disabled
- X.IP "" .5i
- XDays since Jan 1, 1970 that account is disabled
- X.IP "" .5i
- XA reserved field
- X.PP
- XThe password field must be filled.
- XThe encryped password consists of 13 to 24 characters from the
- X64 character alphabet
- Xa thru z, A thru Z, 0 thru 9, \. and /.
- XRefer to \fIcrypt(3)\fR for details on how this string is
- Xinterpreted.
- X.PP
- XThe date of the last password change is given as the number
- Xof days since Jan 1, 1970.
- XThe password may not be changed again until the proper number
- Xof days have passed, and must be changed after the maximum
- Xnumber of days.
- XIf the minimum number of days required is greater than the
- Xmaximum number of day allowed, this password may not be
- Xchanged by the user.
- X.PP
- XAn account is considered to be inactive and is disabled if
- Xthe password is not changed within the specified number of
- Xdays after the password expires.
- XAn account will also be disabled on the specified day
- Xregardless of other password expiration information.
- X.PP
- XThis information supercedes any password or password age
- Xinformation present in \fB/etc/passwd\fR.
- X.PP
- XThis file must not be readable by regular users if password
- Xsecurity is to be maintained.
- X.SH Files
- X/etc/passwd \- user account information
- X.br
- X/etc/shadow \- encrypted user passwords
- X.SH See Also
- Xchage(1),
- Xlogin(1),
- Xpasswd(1),
- Xsu(1),
- Xsulogin(1M),
- Xshadow(3),
- Xpasswd(4),
- Xpwconv(8),
- Xpwunconv(8)
- END_OF_FILE
- if test 2122 -ne `wc -c <'shadow.4'`; then
- echo shar: \"'shadow.4'\" unpacked with wrong size!
- fi
- # end of 'shadow.4'
- fi
- if test -f 'shadow.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'shadow.h'\"
- else
- echo shar: Extracting \"'shadow.h'\" \(1823 characters\)
- sed "s/^X//" >'shadow.h' <<'END_OF_FILE'
- X/*
- X * Copyright 1988, 1989, 1990, John F. Haugh II
- X * All rights reserved.
- X *
- X * Use, duplication, and disclosure prohibited without
- X * the express written permission of the author.
- X */
- X
- X#ifndef _H_SHADOW
- X#define _H_SHADOW
- X
- X/*
- X * This information is not derived from AT&T licensed sources. Posted
- X * to the USENET 11/88, and updated 11/90 with information from SVR4.
- X *
- X * @(#)shadow.h 3.3 09:06:50 12/7/90
- X */
- X
- X#ifdef ITI_AGING
- Xtypedef time_t sptime;
- X#else
- Xtypedef long sptime;
- X#endif
- X
- X/*
- X * Shadow password security file structure.
- X */
- X
- Xstruct spwd {
- X char *sp_namp; /* login name */
- X char *sp_pwdp; /* encrypted password */
- X sptime sp_lstchg; /* date of last change */
- X sptime sp_min; /* minimum number of days between changes */
- X sptime sp_max; /* maximum number of days between changes */
- X sptime sp_warn; /* number of days of warning before password
- X expires */
- X sptime sp_inact; /* number of days after password expires
- X until the account becomes unusable. */
- X sptime sp_expire; /* days since 1/1/70 until account expires */
- X unsigned long sp_flag; /* reserved for future use */
- X};
- X
- X/*
- X * Shadow password security file functions.
- X */
- X
- Xstruct spwd *getspent ();
- Xstruct spwd *getspnam ();
- Xstruct spwd *sgetspent ();
- Xstruct spwd *fgetspent ();
- Xvoid setspent ();
- Xvoid endspent ();
- Xint putspent ();
- X
- X#define SHADOW "/etc/shadow"
- X
- X/*
- X * Shadow group security file structure
- X */
- X
- Xstruct sgrp {
- X char *sg_name; /* group name */
- X char *sg_passwd; /* group password */
- X char **sg_adm; /* group administator list */
- X char **sg_mem; /* group membership list */
- X};
- X
- X/*
- X * Shadow group security file functions.
- X */
- X
- Xstruct sgrp *getsgent ();
- Xstruct sgrp *getsgnam ();
- Xstruct sgrp *sgetsgent ();
- Xstruct sgrp *fgetsgent ();
- Xvoid setsgent ();
- Xvoid endsgent ();
- Xint putsgent ();
- X
- X#define GSHADOW "/etc/gshadow"
- X#endif
- END_OF_FILE
- if test 1823 -ne `wc -c <'shadow.h'`; then
- echo shar: \"'shadow.h'\" unpacked with wrong size!
- fi
- # end of 'shadow.h'
- fi
- if test -f 'sppack.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'sppack.c'\"
- else
- echo shar: Extracting \"'sppack.c'\" \(2186 characters\)
- sed "s/^X//" >'sppack.c' <<'END_OF_FILE'
- X/*
- X * Copyright 1990, 1991, John F. Haugh II
- X * All rights reserved.
- X *
- X * Permission is granted to copy and create derivative works for any
- X * non-commercial purpose, provided this copyright notice is preserved
- X * in all copies of source code, or included in human readable form
- X * and conspicuously displayed on all copies of object code or
- X * distribution media.
- X */
- X
- X#include <stdio.h>
- X#ifdef BSD
- X#include <strings.h>
- X#else
- X#include <string.h>
- X#endif
- X
- X#include "shadow.h"
- X
- X#ifndef lint
- Xstatic char sccsid[] = "@(#)sppack.c 3.2 08:46:24 9/12/91";
- X#endif
- X
- Xint spw_pack (spwd, buf)
- Xstruct spwd *spwd;
- Xchar *buf;
- X{
- X char *cp;
- X
- X cp = buf;
- X strcpy (cp, spwd->sp_namp);
- X cp += strlen (cp) + 1;
- X
- X strcpy (cp, spwd->sp_pwdp);
- X cp += strlen (cp) + 1;
- X
- X memcpy (cp, &spwd->sp_min, sizeof spwd->sp_min);
- X cp += sizeof spwd->sp_min;
- X
- X memcpy (cp, &spwd->sp_max, sizeof spwd->sp_max);
- X cp += sizeof spwd->sp_max;
- X
- X memcpy (cp, &spwd->sp_lstchg, sizeof spwd->sp_lstchg);
- X cp += sizeof spwd->sp_lstchg;
- X
- X memcpy (cp, &spwd->sp_warn, sizeof spwd->sp_warn);
- X cp += sizeof spwd->sp_warn;
- X
- X memcpy (cp, &spwd->sp_inact, sizeof spwd->sp_inact);
- X cp += sizeof spwd->sp_inact;
- X
- X memcpy (cp, &spwd->sp_expire, sizeof spwd->sp_expire);
- X cp += sizeof spwd->sp_expire;
- X
- X memcpy (cp, &spwd->sp_flag, sizeof spwd->sp_flag);
- X cp += sizeof spwd->sp_flag;
- X
- X return cp - buf;
- X}
- X
- Xint spw_unpack (buf, len, spwd)
- Xchar *buf;
- Xint len;
- Xstruct spwd *spwd;
- X{
- X char *org = buf;
- X
- X spwd->sp_namp = buf;
- X buf += strlen (buf) + 1;
- X
- X spwd->sp_pwdp = buf;
- X buf += strlen (buf) + 1;
- X
- X memcpy (&spwd->sp_min, buf, sizeof spwd->sp_min);
- X buf += sizeof spwd->sp_min;
- X
- X memcpy (&spwd->sp_max, buf, sizeof spwd->sp_max);
- X buf += sizeof spwd->sp_max;
- X
- X memcpy (&spwd->sp_lstchg, buf, sizeof spwd->sp_lstchg);
- X buf += sizeof spwd->sp_lstchg;
- X
- X memcpy (&spwd->sp_warn, buf, sizeof spwd->sp_warn);
- X buf += sizeof spwd->sp_warn;
- X
- X memcpy (&spwd->sp_inact, buf, sizeof spwd->sp_inact);
- X buf += sizeof spwd->sp_inact;
- X
- X memcpy (&spwd->sp_expire, buf, sizeof spwd->sp_expire);
- X buf += sizeof spwd->sp_expire;
- X
- X memcpy (&spwd->sp_flag, buf, sizeof spwd->sp_flag);
- X buf += sizeof spwd->sp_flag;
- X
- X if (buf - org > len)
- X return -1;
- X
- X return 0;
- X}
- END_OF_FILE
- if test 2186 -ne `wc -c <'sppack.c'`; then
- echo shar: \"'sppack.c'\" unpacked with wrong size!
- fi
- # end of 'sppack.c'
- fi
- if test -f 'su.1' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'su.1'\"
- else
- echo shar: Extracting \"'su.1'\" \(1697 characters\)
- sed "s/^X//" >'su.1' <<'END_OF_FILE'
- X.\" Copyright 1989, 1990, John F. Haugh II
- X.\" All rights reserved.
- X.\"
- X.\" Use, duplication, and disclosure prohibited without
- X.\" the express written permission of the author.
- X.\"
- X.\" @(#)su.1 3.1 09:34:28 11/21/90
- X.\"
- X.TH SU 1
- X.SH NAME
- Xsu \- Change user ID or become super-user
- X.SH SYNOPSIS
- X.B su
- X[ - ] [ username [ args ] ]
- X.SH DESCRIPTION
- X.I su
- Xis used to become another user during a login session.
- XInvoked without a username, \fIsu\fR defaults to becoming
- Xthe super user.
- XThe optional argument \fB\-\fR may be used to provide an
- Xenvironment similiar to what the user would expect had
- Xthe user logged in directly.
- X.PP
- XAdditional arguments may be provided after the username,
- Xin which case they are supplied to the user\'s login shell.
- XIn particular, an argument of \fB-c\fR will cause the
- Xnext argument to be treated as a command by most command
- Xinterpreters.
- XThe command will be executed under the shell specified by
- X\fB$SHELL\fR, or if undefined, by the one specified in
- X\fI/etc/passwd\fR.
- X.PP
- XThe user will be prompted for a password, if appropriate.
- XInvalid passwords will produce an error message.
- XAll attempts, both valid and invalid, are logged to detect
- Xabuses of the system.
- X.PP
- XThe current environment is passed to the new shell.
- XThe value of \fB$PATH\fR is reset to \fB/bin:/usr/bin\fR
- Xfor normal users, or \fB/bin:/usr/bin:/etc\fR for the super user.
- X.SH CAVEATS
- X.PP
- XThis version of \fIsu\fR has many compilation options, only some of which
- Xmay be in use at any particular site.
- X.SH Files
- X/etc/passwd \- user account information
- X.br
- X/etc/shadow \- encrypted passwords and age information
- X.br
- X$HOME/.profile \- initialization script for default shell
- X.SH See Also
- Xlogin(1),
- Xsh(1)
- END_OF_FILE
- if test 1697 -ne `wc -c <'su.1'`; then
- echo shar: \"'su.1'\" unpacked with wrong size!
- fi
- # end of 'su.1'
- fi
- if test -f 'sub.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'sub.c'\"
- else
- echo shar: Extracting \"'sub.c'\" \(1724 characters\)
- sed "s/^X//" >'sub.c' <<'END_OF_FILE'
- X/*
- X * Copyright 1989, 1990, 1991, John F. Haugh II
- X * All rights reserved.
- X *
- X * Permission is granted to copy and create derivative works for any
- X * non-commercial purpose, provided this copyright notice is preserved
- X * in all copies of source code, or included in human readable form
- X * and conspicuously displayed on all copies of object code or
- X * distribution media.
- X */
- X
- X#include <sys/types.h>
- X#include "config.h"
- X
- X#ifdef USE_SYSLOG
- X#include <syslog.h>
- X
- X#ifndef LOG_WARN
- X#define LOG_WARN LOG_WARNING
- X#endif
- X#endif
- X
- X#include "pwd.h"
- X
- X#ifndef lint
- Xstatic char sccsid[] = "@(#)sub.c 3.3 09:08:19 5/28/91";
- X#endif
- X
- X#define BAD_SUBROOT "Invalid root directory \"%s\"\n"
- X#define BAD_SUBROOT2 "invalid root `%s' for user `%s'\n"
- X#define NO_SUBROOT "Can't change root directory to \"%s\"\n"
- X#define NO_SUBROOT2 "no subsystem root `%s' for user `%s'\n"
- X
- X/*
- X * subsystem - change to subsystem root
- X *
- X * A subsystem login is indicated by the presense of a "*" as
- X * the first character of the login shell. The given home
- X * directory will be used as the root of a new filesystem which
- X * the user is actually logged into.
- X */
- X
- Xvoid subsystem (pw)
- Xstruct passwd *pw;
- X{
- X /*
- X * The new root directory must begin with a "/" character.
- X */
- X
- X if (pw->pw_dir[0] != '/') {
- X printf (BAD_SUBROOT, pw->pw_dir);
- X#ifdef USE_SYSLOG
- X syslog (LOG_WARN, BAD_SUBROOT2, pw->pw_dir, pw->pw_name);
- X closelog ();
- X#endif
- X exit (1);
- X }
- X
- X /*
- X * The directory must be accessible and the current process
- X * must be able to change into it.
- X */
- X
- X if (chdir (pw->pw_dir) || chroot (pw->pw_dir)) {
- X printf (NO_SUBROOT, pw->pw_dir);
- X#ifdef USE_SYSLOG
- X syslog (LOG_WARN, NO_SUBROOT2, pw->pw_dir, pw->pw_name);
- X closelog ();
- X#endif
- X exit (1);
- X }
- X}
- END_OF_FILE
- if test 1724 -ne `wc -c <'sub.c'`; then
- echo shar: \"'sub.c'\" unpacked with wrong size!
- fi
- # end of 'sub.c'
- fi
- if test -f 'sulogin.8' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'sulogin.8'\"
- else
- echo shar: Extracting \"'sulogin.8'\" \(1769 characters\)
- sed "s/^X//" >'sulogin.8' <<'END_OF_FILE'
- X.\" Copyright 1989, 1990, John F. Haugh II
- X.\" All rights reserved.
- X.\"
- X.\" Use, duplication, and disclosure prohibited without
- X.\" the express written permission of the author.
- X.\"
- X.\" @(#)sulogin.8 3.2 07:50:00 7/13/91
- X.\"
- X.TH SULOGIN 8
- X.SH NAME
- Xsulogin \- Single-user login
- X.SH DESCRIPTION
- X.I sulogin
- Xis invoked by \fB/etc/init\fR prior to allowing the user
- Xaccess to the system when in single user mode.
- XThis feature may only be available on certain systems where
- X\fIinit\fR has been modified accordingly, or where the
- X\fB/etc/inittab\fR has an entry for a single user login.
- X.PP
- XThe user is prompted
- X.IP "" .5i
- XType control-d for normal startup,
- X.br
- X(or give root password for system maintenance):
- X.PP
- XIf the user enters the correct root password, a login session
- Xis initiated.
- XWhen \fBEOF\fR is pressed instead, the system enters multi-user
- Xmode.
- X.PP
- XAfter the user exits the single-user shell, or presses \fBEOF\fR,
- Xthe system begins the initialization process required to enter
- Xmulti-user mode.
- X.SH CAVEATS
- X.PP
- XThis command can only be used if \fIinit\fR has been modified to call
- X\fB/etc/sulogin\fR instead of \fB/bin/sh\fR,
- Xor if the user has set the \fIinittab\fR to support a single user
- Xlogin.
- XFor example, the line
- X.br
- X.sp 1
- Xco:s:respawn:/etc/sulogin < /dev/console > /dev/console 2>&1
- X.br
- X.sp 1
- Xshould execute the sulogin command in single user mode.
- X.PP
- XAs complete an environment as possible is created.
- XHowever, various devices may be unmounted or uninitialized and many
- Xof the user commands may be unavailable or nonfunctional as a result.
- X.SH Files
- X/etc/passwd \- user account information
- X.br
- X/etc/shadow \- encrypted passwords and age information
- X.br
- X/.profile \- initialization script for single user shell
- X.SH See Also
- Xlogin(1),
- Xinit(1M),
- Xsh(1)
- END_OF_FILE
- if test 1769 -ne `wc -c <'sulogin.8'`; then
- echo shar: \"'sulogin.8'\" unpacked with wrong size!
- fi
- # end of 'sulogin.8'
- fi
- if test -f 'ttytype.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ttytype.c'\"
- else
- echo shar: Extracting \"'ttytype.c'\" \(1691 characters\)
- sed "s/^X//" >'ttytype.c' <<'END_OF_FILE'
- X/*
- X * Copyright 1989, 1990, 1991, John F. Haugh II
- X * All rights reserved.
- X *
- X * Permission is granted to copy and create derivative works for any
- X * non-commercial purpose, provided this copyright notice is preserved
- X * in all copies of source code, or included in human readable form
- X * and conspicuously displayed on all copies of object code or
- X * distribution media.
- X */
- X
- X#include <stdio.h>
- X#ifndef BSD
- X#include <string.h>
- X#include <memory.h>
- X#else
- X#include <strings.h>
- X#define strchr index
- X#define strrchr rindex
- X#endif
- X#include "config.h"
- X
- X#ifndef lint
- Xstatic char _sccsid[] = "@(#)ttytype.c 3.1 07:43:33 9/17/91";
- X#endif
- X
- Xextern char *getdef_str();
- X
- X/*
- X * ttytype - set ttytype from port to terminal type mapping database
- X */
- X
- Xvoid
- Xttytype (line)
- Xchar *line;
- X{
- X FILE *fp;
- X char buf[BUFSIZ];
- X char termvar[BUFSIZ];
- X char *ttytype;
- X char *cp;
- X char *type;
- X char *port;
- X char *getenv ();
- X
- X if (getenv ("TERM"))
- X return;
- X if ((ttytype=getdef_str("TTYTYPE_FILE")) == NULL )
- X return;
- X if (access (ttytype, 0))
- X return;
- X
- X if (! (fp = fopen (ttytype, "r"))) {
- X perror (ttytype);
- X return;
- X }
- X while (fgets (buf, BUFSIZ, fp)) {
- X if (buf[0] == '#')
- X continue;
- X
- X if (cp = strchr (buf, '\n'))
- X *cp = '\0';
- X
- X#if defined(SUN) || defined(BSD)
- X if ((port = strtok (buf, "\t"))
- X && (type = strtok ((char *) 0, "\t"))
- X && (type = strtok ((char *) 0, "\t"))) {
- X if (strcmp (line, port) == 0)
- X break;
- X }
- X#else /* USG */
- X if ((type = strtok (buf, " \t"))
- X && (port = strtok ((char *) 0, " \t"))) {
- X if (strcmp (line, port) == 0)
- X break;
- X }
- X }
- X#endif
- X if (! feof (fp) && ! ferror (fp)) {
- X strcat (strcpy (termvar, "TERM="), type);
- X addenv (termvar);
- X }
- X fclose (fp);
- X}
- END_OF_FILE
- if test 1691 -ne `wc -c <'ttytype.c'`; then
- echo shar: \"'ttytype.c'\" unpacked with wrong size!
- fi
- # end of 'ttytype.c'
- fi
- if test -f 'valid.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'valid.c'\"
- else
- echo shar: Extracting \"'valid.c'\" \(2323 characters\)
- sed "s/^X//" >'valid.c' <<'END_OF_FILE'
- X/*
- X * Copyright 1989, 1990, 1991, John F. Haugh II
- X * All rights reserved.
- X *
- X * Permission is granted to copy and create derivative works for any
- X * non-commercial purpose, provided this copyright notice is preserved
- X * in all copies of source code, or included in human readable form
- X * and conspicuously displayed on all copies of object code or
- X * distribution media.
- X */
- X
- X#include <stdio.h>
- X#include "pwd.h"
- X#ifdef BSD
- X#include <strings.h>
- X#define strchr index
- X#define strrchr rindex
- X#else
- X#include <string.h>
- X#include <memory.h>
- X#endif
- X#include "config.h"
- X
- X#ifndef lint
- Xstatic char _sccsid[] = "@(#)valid.c 3.4 08:44:15 9/12/91";
- X#endif
- X
- X/*
- X * valid - compare encrypted passwords
- X *
- X * Valid() compares the DES encrypted password from the password file
- X * against the password which the user has entered after it has been
- X * encrypted using the same salt as the original. Entries which do
- X * not have a password file entry have a NULL pw_name field and this
- X * is used to indicate that a dummy salt must be used to encrypt the
- X * password anyway.
- X */
- X
- Xint valid (password, entry)
- Xchar *password;
- Xstruct passwd *entry;
- X{
- X char *encrypt;
- X char *salt;
- X char *pw_encrypt ();
- X
- X /*
- X * Start with blank or empty password entries. Always encrypt
- X * a password if no such user exists. Only if the ID exists and
- X * the password is really empty do you return quickly. This
- X * routine is meant to waste CPU time.
- X */
- X
- X if (entry->pw_name && ! entry->pw_passwd[0]) {
- X if (! password[0])
- X return (1); /* user entered nothing */
- X else
- X return (0); /* user entered something! */
- X }
- X
- X /*
- X * If there is no entry then we need a salt to use.
- X */
- X
- X if (entry->pw_name == (char *) 0 || entry->pw_passwd[0] == '\0')
- X salt = "xx";
- X else
- X salt = entry->pw_passwd;
- X
- X /*
- X * Now, perform the encryption using the salt from before on
- X * the users input. Since we always encrypt the string, it
- X * should be very difficult to determine if the user exists by
- X * looking at execution time.
- X */
- X
- X encrypt = pw_encrypt (password, salt);
- X
- X /*
- X * One last time we must deal with there being no password file
- X * entry for the user. We use the pw_passwd == NULL idiom to
- X * cause non-existent users to not be validated.
- X */
- X
- X if (entry->pw_name && strcmp (encrypt, entry->pw_passwd) == 0)
- X return (1);
- X else
- X return (0);
- X}
- END_OF_FILE
- if test 2323 -ne `wc -c <'valid.c'`; then
- echo shar: \"'valid.c'\" unpacked with wrong size!
- fi
- # end of 'valid.c'
- fi
- echo shar: End of archive 10 \(of 11\).
- cp /dev/null ark10isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 11 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-